const request = require("./http.js");

//查询此用户储值卡余额
var getremainingsum = function (data,callback) {
  request({
    url: "/mall/selectBalance?Id="+data,
    method: "get",
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//管理端/小程序获取储值卡列表
var getStoredCardList = function (data, callback) {
  request({
    url: "/mall/selectStoredAll?Id="+data,
    method: "get",
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//查询此用户储值卡消费记录
var getconsumelist = function (data,callback) {
  request({
    url: "/mall/selectOrder?Id="+data,
    method: "get",
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//小程序客户领取储值卡
var receiveStoreCard = function (data, callback) {
  request({
    url: "/mall/receiveStoreCard",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
module.exports = {
  getremainingsum:getremainingsum, //查询此用户储值卡余额
  getStoredCardList:getStoredCardList,//查询此用户储值卡列表
  getconsumelist:getconsumelist,//查询此用户储值卡消费记录
  receiveStoreCard:receiveStoreCard,//小程序客户领取储值卡
}